package test.controller;

import java.util.HashMap;
import java.util.Map;

import javax.servlet.http.HttpSession;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import com.alibaba.fastjson.JSON;

import test.cache.LanCacheUtil;
import test.service.MainService;

@RequestMapping("/main")
@RestController
public class MianController {
	@Autowired
	private MainService mainService;

	@PostMapping("/detail/{lan_id}")
	public String getDetailMap(@PathVariable String lan_id,HttpSession session) {
		String country=(String) session.getAttribute("country_id");
		String text= LanCacheUtil.getDetailMap(country + "_" + lan_id);
		return text;
	}

	@RequestMapping(value="/infoMap")
	public String getInfoMap(HttpSession session) {
		Map map=new HashMap();
		map.put("country_id", session.getAttribute("country_id"));
		map.put("lan_list", mainService.getInfo());
		String str = JSON.toJSONString(map);
		return str;
	}
	
	

}
